package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.mapper.LkefuMapper;
import cn.gson.fengboot.model.pojos.Lkefu;
import cn.gson.fengboot.model.service.LkefuService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/vue")
public class LkhfwController {
    @Autowired
    LkefuMapper lkefuMapper;
    @Autowired
    LkefuService lkefuService;

    //查询所有客户的服务
    @RequestMapping("/khkefu")
    @ResponseBody
    public Map<String,Object> khkefu(Integer currentPage , Integer pageSize, String search, String fenlei){
        if(currentPage==null || currentPage==' '||pageSize==null||pageSize==' '){
            currentPage=1;
            pageSize=5;
        }
        Page<Object> obj= PageHelper. startPage(  currentPage, pageSize);
        List<Lkefu> lkefus = lkefuMapper.khkefu(search,fenlei);
        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("row",lkefus);
        return map;
    }

    //新增客户服务信息
    @RequestMapping("/addkhwf")
    @ResponseBody
    public  void addkhfw(@RequestBody Lkefu lkefu){
        lkefuService.addkhfw(lkefu);
    }


    //
    @RequestMapping("/khkefulx")
    @ResponseBody
    public Map<String ,Object> khkefulx(String vv){
        Map<String,Object> map= null;
        if (vv.equals("服务类型分布")){
            map= lkefuService.khkefulx();
        }else if (vv.equals("服务方式分布")){
            map= lkefuService.khkefufs();
        }else if (vv.equals("客服花费时间分布")){
            map= lkefuService.khkefuhfsj();
        }else if (vv.equals("客服服务次数top10")){
            map= lkefuService.khkefufwcs();
        }
        else if (vv.equals("服务状态分布")){
            map= lkefuService.khkefuzt();
        }
        return map;
    }

    @RequestMapping("/ydkffb")
    @ResponseBody
    public Map<String ,Object> ydtsfb(String vv){
        Map<String,Object> map= null;
        if (vv.equals("客户服务方式/月度统计")){
            map= lkefuService.khkefufangshi();
        }else if (vv.equals("客户服务类型/月度统计")){
            map= lkefuService.khkefulx();
        }else if (vv.equals("客户服务次数top10")){
            map= lkefuService.khfwfb();
        }else if (vv.equals("客户服务状态/月度统计")){
            map= lkefuService.khkefuzt();
        }
        return map;
    }

    @RequestMapping("/zxtjtu")
    @ResponseBody
    public Map<String ,Object> zxtjtu(String vv){
        Map<String,Object> map= null;
        if (vv.equals("客户服务次数top10")){
            map= lkefuService.khfwfb();
        }else if (vv.equals("服务状态分布")){
            map= lkefuService.khkefuzt();
        }else if (vv.equals("客户服务次数/月度统计")){
            map= lkefuService.ydkffb();
        }
        return map;
    }

}
